package com.apes.auto.car.service;

import com.apes.auto.car.model.Manufacturers;
import com.apes.auto.car.repository.ManufacturersRepository;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ManufacturersService
 * @Description TODO
 * @Author pengyb
 * @Date 2019/7/9 16:00
 * @Version 1.0
 **/
@Service("manufacturersService")
public class ManufacturersService extends DomainService {
    @Autowired
    private ManufacturersRepository manufacturersRepository;

    public Manufacturers save(SimpleRequest request) {
        Manufacturers o = request.getO(Manufacturers.class);
        return manufacturersRepository.saveAndFlush(o);
    }

    public List<Manufacturers> BatchSave(Iterable<Manufacturers> manufacturers) {
        return manufacturersRepository.save(manufacturers);
    }

    public String delete(SimpleRequest request) {
        Manufacturers o = request.getO(Manufacturers.class);
        manufacturersRepository.delete(o.getId());
        return "删除成功";
    }
}
